home *** CD-ROM | disk | FTP | other *** search
Korn shell script | 1992-09-20 | 5.5 KB | 208 lines |
- #!/bin/ksh
- ###############################################################################
- # sendproc - a front end to the MH send command
- #
- # Gregory F. March (march@nynexst.com)
- #
- #------------------------------------------------------------------------------
- #
- # sendproc provides the following additions to the MH send command:
- #
- # Addition of an X-Face: mail header
- # Addition of an Fcc: mail header
- # Addition of a .signature
- #
- # All of the above can be turned off. The default is on with the filespecs
- # set below. The files used can be changed via the command line as well.
- #
- # Search for the line containing "CONFIGURE" to see what you can change.
- #
- # NOTE: I guarantee nothing.
- #
- ###############################################################################
-
- # CONFIGURE: Location of the MH send program
- SEND=/home/bonehead/local/bin/send
-
- # CONFIGURE: Location of the internal .sig file
- INTERNAL=$HOME/.signature.internal
-
- # CONFIGURE: Location of the external .sig file
- INTERNAL=$HOME/.signature.external
-
- # CONFIGURE: You may want to change these...
-
- XFACE=1 # Yes, we have a face file
- XFACEFN=$HOME/.face # and this is where it is.
-
- SIG=1 # Yes, send a signature
-
- FCC=1 # Yes, we want to save outbound mail
- FCCFN=outbox # and this is where we will save it
-
- TMPFILE=/tmp/mh-send.$$ # Temp mail file
- ARGN=0 # argument counter
-
- while [ $# -gt 0 ] # Check out args...
- do
- case $1 in
- -help) print ""
- print "sendproc accepts:"
- print " -noxface"
- print " -xface facefile"
- print " -nofcc"
- print " -fcc fccfile"
- print " -(nosig)nature"
- print " -(sig)nature sigfile"
- print ""
- print "Defaults:"
- print " -xface $HOME/.face -fcc outbox"
- print ""
- print "The default for the .signature depends on 'friends'. See the sendproc script."
- print ""
- print "sendproc also accepts 'send' arguments:"
- print ""
-
- $SEND -help
-
- exit 1 ;;
- -noxface) XFACE=0 ;;
- -xface) if [ -f "$2" ]
- then
- shift
- XFACEFN=$1
- else
- print sendproc: "$2" is not a valid file
- exit 1
- fi ;;
- -nosig*) SIG=0 ;;
- -sig*) SIG=2
-
- if [ -f "$2" ]
- then
- shift
- SIGFN=$1
- else
- print sendproc: "$2" is not a valid file
- exit 1
- fi ;;
- -nofcc) FCC=0 ;;
- -fcc) if [ -f "$2" ]
- then
- shift
- FCCFN=$1
- else
- print sendproc: "$2" is not a valid file
- exit 1
- fi ;;
-
- # Just record all args we don't know about and pass them to
- # the send program
-
- *) args[$ARGN]=$1
- let ARGN=$ARGN+1 ;;
- esac
-
- shift # next arg
- done
-
- DRAFT=${args[$ARGN-1]} # ASSUMPTION: last arg is the draft file
-
- cat $DRAFT | ( # Build draft file extensions
-
- # Face stuff...
-
- if [ $XFACE -eq 1 ] # X-Face: stuff
- then
- if [ -f "$XFACEFN" ]
- then
- print -n X-Face:
- cat $XFACEFN
- fi
- fi
-
- if [ $FCC -eq 1 ] # Fcc: stuff
- then
- print "Fcc: $FCCFN"
- fi
-
- IFS_ORIG=$IFS
-
- IFS=
- SIGFLAG=1 # Default sig is 'internal'
-
- # CONFIGURE: You probably want to change this list...
-
- while read line
- do
- echo "$line"
- case $line in
- "") break ;; # Blank line after the subject...
- To:*march*) SIGFLAG="0" ;; # friends...
- To:*marty*) SIGFLAG="0" ;; # friends...
- To:*leggiero*) SIGFLAG="0" ;; # friends...
- To:*jason*) SIGFLAG="0" ;; # friends...
- To:*mary*) SIGFLAG="0" ;; # friends...
- To:*rrad*) SIGFLAG="0" ;; # friends...
- To:*sheppard*) SIGFLAG="0" ;; # friends...
- To:*balick*) SIGFLAG="0" ;; # friends...
- To:*zhigang*) SIGFLAG="0" ;; # friends...
- To:*atul*) SIGFLAG="0" ;; # friends...
- To:*wittner*) SIGFLAG="0" ;; # friends...
- To:*gen*) SIGFLAG="0" ;; # friends...
- To:*clare*) SIGFLAG="0" ;; # friends...
- To:*amyliv*) SIGFLAG="0" ;; # friends...
- To:*sanders*) SIGFLAG="0" ;; # friends...
- To:*laxmi*) SIGFLAG="0" ;; # friends...
- To:*rsmith*) SIGFLAG="0" ;; # friends...
- To:*aispeech*) SIGFLAG="0" ;; # friends...
- To:*jrs*) SIGFLAG="0" ;; # friends...
- To:*sara*) SIGFLAG="0" ;; # friends...
- To:*dina*) SIGFLAG="0" ;; # friends...
- To:*ben*) SIGFLAG="0" ;; # friends...
- To:*dav*) SIGFLAG="0" ;; # friends...
- To:*kimsilv*) SIGFLAG="0" ;; # friends...
- To:*lisar*) SIGFLAG="0" ;; # friends...
- To:*jules*) SIGFLAG="0" ;; # friends...
- To:*ken*) SIGFLAG="0" ;; # friends...
- To:*ashokk*) SIGFLAG="0" ;; # friends...
- To:*pitrelli*) SIGFLAG="0" ;; # friends...
- To:*smehta*) SIGFLAG="0" ;; # friends...
- To:*srs*) SIGFLAG="0" ;; # friends...
- To:*asadi*) SIGFLAG="0" ;; # friends...
- To:*hcl*) SIGFLAG="0" ;; # friends...
- To:*nancyk*) SIGFLAG="0" ;; # friends...
- To:*em*) SIGFLAG="0" ;; # friends...
- To:*weather*) SIGFLAG="1" ;; # internal weather mailing list
- To:*c++*) SIGFLAG="1" ;; # internal c++ mailing list
- To:*nasanews*) SIGFLAG="1" ;; # internal nasanews mailing list
- To:*recog*) SIGFLAG="0" ;; # internal speech recog mailing list
- To:*tam*) SIGFLAG="0" ;; # internal "Talk About Money" list
- To:*synth*) SIGFLAG="0" ;; # internal speech synth mailing list
- To:*@* | To:*!*) SIGFLAG="2" ;; # External mail?
- esac
- done
-
- IFS=$IFS_ORIG
-
- cat # the message
-
- case $SIG in
- 0) break ;;
- 1) case $SIGFLAG in
- "0") break ;;
- "1") cat $INTERNAL ;;
- "2") cat $EXTERNAL ;;
- esac ;;
- 2) cat $SIGFN ;;
- esac
-
- ) > $TMPFILE
-
- # Could I do this with a -nodraft option to send?
-
- rm -f $DRAFT
- mv $TMPFILE $DRAFT
-
- $SEND ${args[*]} # send new draft
-